package com.yenlien.traceyun.milk.controller;

import com.yenlien.traceyun.business.interceptor.UserAuthUtil;
import com.yenlien.traceyun.milk.entity.MilkManage;
import com.yenlien.traceyun.milk.service.MilkManageService;
import com.yenlien.traceyun.webase.controller.BaseController;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Date 2022/10/11
 * @Author jiaLong
 * @Descript 奶站管理
 */
@Api(tags = "奶站管理")
@RestController
@RequestMapping("/manage")
public class MilkManageController extends BaseController {

    @Autowired
    private MilkManageService milkManageService;

    @PostMapping(value = "/save")
    public Object save(@RequestBody MilkManage milkManage) {
        return success(milkManageService.save(milkManage));
    }

    @PostMapping(value = "/findByList")
    public Object findByList(@RequestBody MilkManage milkManage) {
        if(StringUtils.isBlank(milkManage.getCompanyId())){
            milkManage.setCompanyId(UserAuthUtil.getLoginUser().getCompanyId());
        }
        return success(milkManageService.findByList(milkManage));
    }

    @GetMapping(value = "/findAll")
    public Object findAll() {
        return success(milkManageService.findAll());
    }


    @GetMapping(value = "/findById/{id}")
    public Object findById(@PathVariable("id") String id) {
        return success(milkManageService.findById(id));
    }





}
